package com.sczmgk.track.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;

/**
 * 自定义圆头像
 * @author Administrator
 *
 */
public class CircularPaddingImage extends MaskedImage {
	public CircularPaddingImage(Context paramContext) {
		super(paramContext);
	}

	public CircularPaddingImage(Context paramContext, AttributeSet paramAttributeSet) {
		super(paramContext, paramAttributeSet);
	}

	public CircularPaddingImage(Context paramContext, AttributeSet paramAttributeSet,
								int paramInt) {
		super(paramContext, paramAttributeSet, paramInt);
	}

	/**
	 * 创建圆形
	 * 1.创建一个矩形的bitMap
	 * 2.建一个之前矩形大小的画布（传处bitMap）
	 * 3.建一个与画布同样大小的圆形
	 * 4.在画布上画圆
	 * 5.返回画圆后的bitMap
	 */
	public Bitmap createMask() {
		int width = getWidth();
		int height = getHeight();
		Bitmap.Config localConfig = Bitmap.Config.ARGB_8888;
		Bitmap localBitmap = Bitmap.createBitmap(width, height, localConfig);//创建一个矩形的bitMap
		Canvas localCanvas = new Canvas(localBitmap);//建一个之前矩形大小的画布
		Paint localPaint = new Paint(1);
		localPaint.setColor(Color.GREEN);
		float width_f = getWidth();
		float height_f = getHeight();
		RectF localRectF = new RectF(0.0F, 0.0F, width_f, height_f);//建一个与画布同样大小的圆形
		localCanvas.drawOval(localRectF, localPaint);//画圆
		return localBitmap;//返回图片
	}
}